package uk.co.q3c.deplan.server.unit.domain;

import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import uk.co.q3c.deplan.client.domain.AbstractDomainObject;
import uk.co.q3c.deplan.client.domain.dag.ChangeInvalidException;
import uk.co.q3c.deplan.client.domain.dag.CycleDetectedException;
import uk.co.q3c.deplan.client.domain.resource.PersistenceReferenceException;
import util.TestDomainObjectForTree;

@Test
public class DomainObject_UT {

	AbstractDomainObject ado;

	@BeforeMethod
	protected void beforeMethod() {
		ado = new TestDomainObjectForTree();
	}

	public void discard() throws CycleDetectedException, ChangeInvalidException, PersistenceReferenceException {
		Assert.assertNull(ado.getDiscardedDate());
		ado.setDiscarded(true);
		// discarded date set as well
		Assert.assertNotNull(ado.getDiscardedDate());
		Assert.assertTrue(ado.getDiscarded());

		// undiscard, discarded date should be null
		ado.setDiscarded(false);
		Assert.assertNull(ado.getDiscardedDate());

	}
}
